home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Sound / PreludeAMP / src / layer2.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-16  |  6.0 KB  |  191 lines

  1. /* this file is a part of amp software, (C) tomislav uzelac 1996,1997
  2. */
  3. /* layer2.h
  4.  * Tomislav Uzelac - cca. Feb 1996
  5.  */
  6.  
  7.  
  8. extern int layer2_frame(struct AUDIO_HEADER *header,int cnt);
  9.  
  10. #ifdef LAYER2
  11.  
  12. int layer2_frame(struct AUDIO_HEADER *header,int cnt);
  13. float requantize_sample(unsigned short s4,unsigned short nlevels,float c,float d,float factor);
  14. void convert_samplecode(unsigned int samplecode,unsigned int nlevels,unsigned short* sb_sample_buf);
  15.  
  16. char t_nbal0[27]={4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2};
  17. char t_nbal1[30]={4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2};
  18. char t_nbal2[8] ={4,4,3,3,3,3,3,3};
  19. char t_nbal3[12]={4,4,3,3,3,3,3,3,3,3,3,3};
  20. char t_nbalMPG2[30]={4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
  21.  
  22. char t_alloc0[27][16] = {    /* table B.2a ISO/IEC 11172-3 */
  23. {0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
  24. {0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
  25. {0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
  26. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  27. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  28. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  29. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  30. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  31. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  32. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  33. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  34. {0,1,2,3,4,5,6,17},
  35. {0,1,2,3,4,5,6,17},
  36. {0,1,2,3,4,5,6,17},
  37. {0,1,2,3,4,5,6,17},
  38. {0,1,2,3,4,5,6,17},
  39. {0,1,2,3,4,5,6,17},
  40. {0,1,2,3,4,5,6,17},
  41. {0,1,2,3,4,5,6,17},
  42. {0,1,2,3,4,5,6,17},
  43. {0,1,2,3,4,5,6,17},
  44. {0,1,2,3,4,5,6,17},
  45. {0,1,2,3,4,5,6,17},
  46. {0,1,2,17},
  47. {0,1,2,17},
  48. {0,1,2,17},
  49. {0,1,2,17}};
  50.  
  51. char t_alloc1[30][16] = {        /* table B.2b ISO/IEC 11172-3 */
  52. {0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
  53. {0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
  54. {0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
  55. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  56. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  57. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  58. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  59. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  60. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  61. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  62. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
  63. {0,1,2,3,4,5,6,17},
  64. {0,1,2,3,4,5,6,17},
  65. {0,1,2,3,4,5,6,17},
  66. {0,1,2,3,4,5,6,17},
  67. {0,1,2,3,4,5,6,17},
  68. {0,1,2,3,4,5,6,17},
  69. {0,1,2,3,4,5,6,17},
  70. {0,1,2,3,4,5,6,17},
  71. {0,1,2,3,4,5,6,17},
  72. {0,1,2,3,4,5,6,17},
  73. {0,1,2,3,4,5,6,17},
  74. {0,1,2,3,4,5,6,17},
  75. {0,1,2,17},
  76. {0,1,2,17},
  77. {0,1,2,17},
  78. {0,1,2,17},
  79. {0,1,2,17},
  80. {0,1,2,17},
  81. {0,1,2,17}};
  82.  
  83. char t_alloc2[8][16] = {       /* table B.2c ISO/IEC 11172-3 */
  84. {0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
  85. {0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
  86. {0,1,2,4,5,6,7,127},
  87. {0,1,2,4,5,6,7,127},
  88. {0,1,2,4,5,6,7,127},
  89. {0,1,2,4,5,6,7,127},
  90. {0,1,2,4,5,6,7,127},
  91. {0,1,2,4,5,6,7,127}};
  92.  
  93. char t_alloc3[12][16] = {       /* table B.2d ISO/IEC 11172-3 */
  94. {0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
  95. {0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
  96. {0,1,2,4,5,6,7,127},
  97. {0,1,2,4,5,6,7,127},
  98. {0,1,2,4,5,6,7,127},
  99. {0,1,2,4,5,6,7,127},
  100. {0,1,2,4,5,6,7,127},
  101. {0,1,2,4,5,6,7,127},
  102. {0,1,2,4,5,6,7,127},
  103. {0,1,2,4,5,6,7,127},
  104. {0,1,2,4,5,6,7,127},
  105. {0,1,2,4,5,6,7,127}};
  106.  
  107. char t_allocMPG2[30][16] = {    /* table B.1. ISO/IEC 13818-3 */
  108. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
  109. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
  110. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
  111. {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
  112. {0,1,2,4,5,6,7,8},
  113. {0,1,2,4,5,6,7,8},
  114. {0,1,2,4,5,6,7,8},
  115. {0,1,2,4,5,6,7,8},
  116. {0,1,2,4,5,6,7,8},
  117. {0,1,2,4,5,6,7,8},
  118. {0,1,2,4,5,6,7,8},
  119. {0,1,2,4},
  120. {0,1,2,4},
  121. {0,1,2,4},
  122. {0,1,2,4},
  123. {0,1,2,4},
  124. {0,1,2,4},
  125. {0,1,2,4},
  126. {0,1,2,4},
  127. {0,1,2,4},
  128. {0,1,2,4},
  129. {0,1,2,4},
  130. {0,1,2,4},
  131. {0,1,2,4},
  132. {0,1,2,4},
  133. {0,1,2,4},
  134. {0,1,2,4},
  135. {0,1,2,4},
  136. {0,1,2,4},
  137. {0,1,2,4}};
  138.  
  139. double t_scalefactor[64] = {
  140. 2.00000000000000, 1.58740105196820, 1.25992104989487,
  141. 1.00000000000000, 0.79370052598410, 0.62996052494744, 0.50000000000000,
  142. 0.39685026299205, 0.31498026247372, 0.25000000000000, 0.19842513149602,
  143. 0.15749013123686, 0.12500000000000, 0.09921256574801, 0.07874506561843,
  144. 0.06250000000000, 0.04960628287401, 0.03937253280921, 0.03125000000000,
  145. 0.02480314143700, 0.01968626640461, 0.01562500000000, 0.01240157071850,
  146. 0.00984313320230, 0.00781250000000, 0.00620078535925, 0.00492156660115,
  147. 0.00390625000000, 0.00310039267963, 0.00246078330058, 0.00195312500000,
  148. 0.00155019633981, 0.00123039165029, 0.00097656250000, 0.00077509816991,
  149. 0.00061519582514, 0.00048828125000, 0.00038754908495, 0.00030759791257,
  150. 0.00024414062500, 0.00019377454248, 0.00015379895629, 0.00012207031250,
  151. 0.00009688727124, 0.00007689947814, 0.00006103515625, 0.00004844363562,
  152. 0.00003844973907, 0.00003051757813, 0.00002422181781, 0.00001922486954,
  153. 0.00001525878906, 0.00001211090890, 0.00000961243477, 0.00000762939453,
  154. 0.00000605545445, 0.00000480621738, 0.00000381469727, 0.00000302772723,
  155. 0.00000240310869, 0.00000190734863, 0.00000151386361, 0.00000120155435,
  156. 1E-20};
  157.  
  158. double t_c[18] = { 0,
  159.          1.33333333333, 1.60000000000, 1.14285714286,
  160.                  1.77777777777, 1.06666666666, 1.03225806452,
  161.                  1.01587301587, 1.00787401575, 1.00392156863,
  162.                  1.00195694716, 1.00097751711, 1.00048851979,
  163.                  1.00024420024, 1.00012208522, 1.00006103888,
  164.                  1.00003051851, 1.00001525902 };
  165.                  
  166. double t_d[18] = {0,
  167.    0.500000000,  0.500000000,  0.250000000,  0.500000000,
  168.    0.125000000,  0.062500000,  0.031250000,  0.015625000,
  169.    0.007812500,  0.003906250,  0.001953125,  0.0009765625,
  170.    0.00048828125,0.00024414063,0.00012207031,
  171.    0.00006103516,0.00003051758 };
  172.  
  173. float t_dd[18]={ -1, -0.5, -0.5, -0.75, -0.5, -0.875, -0.9375, -0.96875, -0.984375,
  174. -0.992188, -0.996094, -0.998047, -0.999023, -0.999512, -0.999756, -0.999878, -0.999939,
  175. -0.999969};
  176.    
  177. char t_grouping[18]={0,3,5,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0};
  178.  
  179. /*
  180. int t_nlevels[18] = {0,3,5,7,9,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
  181. */
  182. int t_nlevels[18] = {0,3,7,7,15,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
  183.  
  184.  
  185. float t_nli[18]={ 0, 0.5, 0.25, 0.25, 0.125, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125, 0.00390625,
  186. 0.00195313, 0.000976563, 0.000488281, 0.000244141, 0.00012207, 6.10352e-05, 3.05176e-05}; 
  187.  
  188. int t_bpc[18] = {0,5,7,3,10,4,5,6,7,8,9,10,11,12,13,14,15,16};
  189.  
  190. #endif /* LAYER2 */
  191.